Skip to content

Add automatic client reconnection with exponential backoff#188

Open
kfirfer wants to merge 13 commits intoekzhang:mainfrom
kfirfer:reconnect
Open

Add automatic client reconnection with exponential backoff#188
kfirfer wants to merge 13 commits intoekzhang:mainfrom
kfirfer:reconnect

Conversation

@kfirfer
Copy link
Copy Markdown

@kfirfer kfirfer commented Feb 20, 2026

Summary

  • Automatic reconnection with exponential backoff and jitter on connection loss (enabled by default)
  • Heartbeat timeout (8s) on the client to detect dead connections
  • TCP keepalive on control connections (client + server) via socket2
  • Authentication errors are classified as fatal and never retried
  • New CLI flags: --no-reconnect, --max-reconnect-delay

Test plan

  • Unit tests for ExponentialBackoff and is_auth_error()
  • Manual: client reconnects after server restart
  • Manual: --no-reconnect exits on disconnect
  • Manual: wrong secret exits immediately without retrying

…ing corrections, tokio version bump, and test impact clarifications
…heartbeat timeout

- Add heartbeat timeout to client control connection using server heartbeats for dead connection detection
- Introduce exponential backoff with jitter for reconnection delays
- Add CLI flags: --no-reconnect to disable auto-reconnect, --max-reconnect-delay to configure backoff cap
- Classify authentication errors as fatal (never retried), all others retried automatically
- Configure TCP keepalive on control connections for OS-level dead connection detection
- Update documentation (README.md, CLAUDE.md) to describe reconnection behavior and new flags
- Add unit tests for backoff logic and error classification
…live

- Add explicit notes to authentication error messages to clarify their use in fatal error classification
- Update client and server to log a warning instead of failing if TCP keepalive cannot be set
- Refine no_reconnect mode to exit cleanly on disconnect and fail on authentication errors
- Enforce minimum value for max_reconnect_delay CLI argument
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant